package com.lsh.vipres.config;

import com.lsh.vipres.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 登录拦截器配置
 * @Author: lish
 * @Date: 2021/7/22 13:30
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Autowired
    LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginInterceptor);
        //拦截配置
        interceptorRegistration.addPathPatterns("/**");
        //排除配置
        interceptorRegistration.excludePathPatterns("/pages/login.html");
        interceptorRegistration.excludePathPatterns("/pages/top.html");
        interceptorRegistration.excludePathPatterns("/pages/bottom.html");
        interceptorRegistration.excludePathPatterns("/pages/register.html");
        interceptorRegistration.excludePathPatterns("/user/login");
        interceptorRegistration.excludePathPatterns("/static/**");
        interceptorRegistration.excludePathPatterns("/lib/**");
        interceptorRegistration.excludePathPatterns("/css/**");
        interceptorRegistration.excludePathPatterns("/image/**");
        interceptorRegistration.excludePathPatterns("/temp/**");
        interceptorRegistration.excludePathPatterns("/404.html");
        interceptorRegistration.excludePathPatterns("/index.html");
        interceptorRegistration.excludePathPatterns("/pages/news.html");
        interceptorRegistration.excludePathPatterns("/pages/notice.html");
        interceptorRegistration.excludePathPatterns("/");
    }
}
